#include<bits/stdc++.h>
using namespace std;
int main()
{
	int k,n,sum;
	cin>>n>>k;
	sum=n;
	while(n>=k)
	{
	    sum+=n/k;
	    n=n%k+n/k;
	}
	cout<<sum;
	return 0;
}
